<?php
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Traits\HasUuid;

class UserModel extends Model
{
    use HasFactory, HasUuid, SoftDeletes;

    protected $table = 'users';

    protected $fillable = [];

	protected $hidden = ["deleted_at"];

    public function role(): HasMany
    {
        return $this->hasMany(UserHasRoleModel::class, 'user_id', 'id');
    }

    public function organization(): BelongsToMany
    {
        return $this->belongsToMany(OrganizationModel::class, 'organization_users',
            'user_id', 'organization_id','id','id');
    }

    public function roles(): BelongsToMany
    {
        return $this->belongsToMany(RoleModel::class, 'user_has_roles',
            'user_id', 'role_id','id','id');
    }
}
